package com.epfresh.supplier.entity;

import android.text.TextUtils;

import com.google.gson.Gson;

/**
 * Created by wzh on 2016/5/11.
 */
public class StoreInfo {

    private Store store;

    //未认证（0），已经提交（1），已认证（2），认证失败（3）
    private String certStatus;
//bankCardCount  certType

    private int bankCardCount;
    private String certType;
    //银行卡个人还是企业,1个人,2企业
    private String bankCardType;


    private String storeStatus;

    public String getStoreStatus() {
        return storeStatus;
    }

    public void setStoreStatus(String storeStatus) {
        this.storeStatus = storeStatus;
    }

    public int getBankCardCount() {
        return bankCardCount;
    }

    public void setBankCardCount(int bankCardCount) {
        this.bankCardCount = bankCardCount;
    }

    public String getCertType() {
        return certType;
    }

    public void setCertType(String certType) {
        this.certType = certType;
    }

    public boolean isLegal() {
        if (store == null) {

        } else {
            store.isLegal();
        }
        return !TextUtils.isEmpty(certStatus);
    }

    public Store getStore() {
        return store;
    }

    public void setStore(Store store) {
        this.store = store;
    }

    public String getCertStatus() {
        return certStatus == null ? "0" : certStatus;
    }

    public void setCertStatus(String certStatus) {
        this.certStatus = certStatus;
    }


    public boolean canBank() {

        return store != null && !"0".equals(certStatus) && certType != null;
//                &&
//
//                ("0".equals(store.getAuditStatus())
//                ||"1".equals(store.getAuditStatus())
//                ||"2".equals(store.getAuditStatus()));
    }

    public boolean isOpenStore() {
        return ("2".equals(storeStatus));
    }

    public boolean isStoreReject() {
        return ((getStore() != null && "2".equals(getStore().getAuditStatus())));
    }

    public boolean isStoreEmpty() {
        return store == null;
    }

    public boolean isDc() {

        if (getStore() != null && getStore().isDc()) {
            return true;
        }
        return false;

    }

    public String getBankCardType() {
        return bankCardType;
    }

    public void setBankCardType(String bankCartType) {
        this.bankCardType = bankCartType;
    }

    public String encryptStoreInfo() {
        //可以再加密
        return new Gson().toJson(this);
    }

    public static StoreInfo decryptStoreInfo(String encryptStr) {
        //可以增加解密
        return new Gson().fromJson(encryptStr, StoreInfo.class);
    }

    public String getManagerName(){
        String managerName = "";
        if (store != null){
            managerName = store.getManagerName();
        }
        return managerName;
    }
    public String getManagerPhone(){
        String managerPhone = "";
        if (store != null){
            managerPhone = store.getManagerPhone();
        }
        return managerPhone;
    }

    public String getMangerInfo(){
        return getManagerName()+"  "+getManagerPhone();
    }

    public boolean isFirstOpen() {

//        {
//            "bankCardCount": 0,
//                "store": null,
//                "certType": null,
//                "certStatus": 0
//        }


        return store == null || "-1".equals(store.getAuditStatus());
    }

    @Override
    public String toString() {
        return "StoreInfo{" +
                "store=" + store +
                ", certStatus='" + certStatus + '\'' +
                ", bankCardCount=" + bankCardCount +
                ", certType='" + certType + '\'' +
                '}';
    }
}
